<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  

<script>
  // function getTotal (str) {
  //   var arr = str.split('')

  //   console.log(arr)
  //   return arr.reduce(function (prev, next) {
  //     return Number(prev) + Number(next)
  //   })
  // }

  // var total = getTotal('4685132687983213')

  // console.log(total)

  // var str = '789'

  // console.log(str.split('')[0])
  // console.log(str.split('')[1])
  // console.log(str.split('')[2])

  // var arr100 = []

  // for (var i = 0; i <= 100; i++) {
  //   arr100.push(i)
  // }

  // arr100 = arr100.filter(function (item, index) {
  //   return !(item % 2)
  // })

  // console.log(arr100)

  // var sortArr = ['78', '21', '99']

  // console.log(sortArr.sort(function (prev, next) {
  //   return prev - next
  // }))

  var arr = [1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9]
           //0 1 2 3 4 5 6 7 8 9 10
  var obj = {}

    // obj[1] = 1
    // obj[2] = 3
    // obj[3] = 5
    // obj[4] = 7
    // obj[5] = 9

  arr.forEach(function (item, index) {
    obj[item] = index
  })

  arr = Object.keys(obj).map(function (item) {
    return Number(item)
  })

  console.log(arr)

  //赋值解构
  var arr =[1,2,3,4]
  var newarr = [... arr]

  arr[0] = 100

  console.log(arr)
  console.log(newarr)
</script>

</body>
</html>